import { Injectable, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router, NavigationStart } from '@angular/router';

export class AccessGuard implements CanActivate {
    constructor( private router: Router, @Inject(DOCUMENT) private document: any ) {}
    canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
        if (localStorage.getItem('info')) {
            return true;
        } else {
            alert('未检测到您的个人信息，请前往新建');
            this.router.navigate(['index-page']);
        }
    }
}
